package jjn.acwing.algorithm_basic.chapter1.two_pointer;

import java.util.Scanner;

/**
 * @author Jjn
 * @since 2023-09-23 09:40
 */
public class Acwing800 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        int x = scanner.nextInt();
        int[] a = new int[n];
        int[] b = new int[m];
        for (int i = 0; i < n; i++) {
            a[i] = scanner.nextInt();
        }
        for (int i = 0; i < m; i++) {
            b[i] = scanner.nextInt();
        }
        int j = m - 1;
        for (int i = 0; i < n; i++) {
            while (j >= 0 && a[i] + b[j] > x) {
                j--;
            }
            if (a[i] + b[j] == x) {
                System.out.printf("%d %d\n", i, j);
                break;
            }
        }
    }
}
